package com.htl.集合;

import java.util.LinkedHashSet;

public class LinkedHashSet__test2 {
    public static void main(String[] args) {
        LinkedHashSet linkedHashSet = new LinkedHashSet();
        linkedHashSet.add(new A(1));
        linkedHashSet.add(new A(2));
        System.out.println(linkedHashSet);
    }
}

class A{
    private int num;
    public A(int num) {
        this.num = num;
    }
    @Override
    public String toString() {
        return "A{" +
                "num=" + num +
                '}';
    }
    @Override
    public boolean equals(Object o) {
        return false;
    }
    @Override
    public int hashCode() {
        if(num == 1) return 1;
        if(num == 2) return 1;
        return 0;
    }
}
